<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app"></div>
    <div id="app1" style="width: 100px;height: 100px;"></div>

    <script src="../node_modules/@vue/reactivity/dist/reactivity.global.js"></script>

    <script>
      let { ref,effect,reactive,toRef,toRefs } = VueReactivity;

      // ref测试
      let color = ref("red")
      effect(()=>{
        app1.style.backgroundColor = color.value
      })
      setTimeout(()=>{
        color.value = "blue"
      },1000)

      // toRefs测试
      let state = reactive({
        name:"王五",
        age:12
      })
      let {name,age} = toRefs(state)
      
      effect(()=>{
        app.innerHTML = `${name.value} - ${age.value}`
      })

      setTimeout(()=>{
        name.value = "张三123"
      },1000)
    </script>
</body>
</html>